package com.nulldev.util.data.FastMath.impls;

import com.nulldev.util.data.FastMath.Math;

@SuppressWarnings("unused")
public class LibGDX extends Math {

	public static final LibGDX INSTANCE = new LibGDX();

	public LibGDX() {
		super();
	}

	public static final float BF_PI = 3.1415927f;
	private static final int BF_SIN_BITS = 14;
	private static final int BF_SIN_MASK = 16383;
	private static final int BF_SIN_COUNT = 16384;
	private static final float BF_radFull = 6.2831855f;
	private static final float BF_degFull = 360.0f;
	private static final float BF_radToIndex = 2607.5945f;
	private static final float BF_degToIndex = 45.511112f;
	public static final float BF_degreesToRadians = 0.017453292f;
	private static final float[] BF_table;

	public static float sin(final float radians) {
		return BF_table[(int) (radians * 2607.5945f) & 0x3FFF];
	}

	public static double sin(final double radians) {
		return BF_table[(int) (radians * 2607.5945f) & 0x3FFF];
	}

	public static float cos(final float radians) {
		return BF_table[(int) ((radians + 1.5707964f) * 2607.5945f) & 0x3FFF];
	}

	public static double cos(final double radians) {
		return BF_table[(int) ((radians + 1.5707964f) * 2607.5945f) & 0x3FFF];
	}

	static {
		BF_table = new float[16384];
		for (int i = 0; i < 16384; ++i) {
			BF_table[i] = (float) Math.sin((i + 0.5f) / 16384.0f * 6.2831855f);
		}
		for (int i = 0; i < 360; i += 90) {
			BF_table[(int) (i * 45.511112f) & 0x3FFF] = (float) Math.sin(i * 0.017453292f);
		}
	}
}
